/**
 * Copyright 2008-2009 HAN.BIFANG
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */
package han.bifang.gwt.client.domain.content;

import han.bifang.gwt.client.common.Content;
import han.bifang.gwt.client.common.entity.BusInnerService;
import han.bifang.gwt.client.common.entity.JmsBinding;
import han.bifang.gwt.client.common.entity.JmsBindingWrapper;
import han.bifang.gwt.client.common.entity.NormalJms;
import han.bifang.gwt.client.common.entity.SoapBinding;
import han.bifang.gwt.client.communicate.BifangGWTServiceAsync;
import han.bifang.gwt.client.domain.DomainMessages;

import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
import com.google.gwt.user.client.ui.HTMLTable.ColumnFormatter;

/**
 * 
 * @Author Kent
 */
public class BusInnerServiceContent extends Content {
	private DomainMessages cons;
	private BifangGWTServiceAsync service;
	
	public BusInnerServiceContent(DomainMessages cons,BifangGWTServiceAsync service,BusInnerService s){
		this.cons = cons;
		this.service = service;
		VerticalPanel p1 = new VerticalPanel();
		p1.setWidth("100%");
		p1.setBorderWidth(0);
		
		
		Grid table1 = new Grid(1,2);
		table1.setWidth("70%");
		ColumnFormatter cf = table1.getColumnFormatter();
		cf.setWidth(0, "20%");
		cf.setWidth(1, "60%");

		table1.setCellPadding(1);
		table1.setCellSpacing(1);
		table1.setBorderWidth(1);

		CellFormatter ff = table1.getCellFormatter();
		ff.setStyleName(0, 0, "tablecol");
		
		table1.setHTML(0, 0, cons.notifyService());
		table1.setHTML(0, 1, s.getNotifyServiceCode());
		
		p1.add(table1);
		p1.add(new HTML("&nbsp;"));
		p1.add(new HTML(cons.notifyServiceBinding()));
		
		
		JmsBindingWrapper w = s.getJmsBinding();
		JmsBinding jb = w.getJmsBinding();
		NormalJms info = (NormalJms) w.getInfo();

		Grid table = new Grid(9, 2);
		table.setWidth("70%");
		cf = table.getColumnFormatter();
		cf.setWidth(0, "20%");
		cf.setWidth(1, "60%");

		table.setCellPadding(1);
		table.setCellSpacing(1);
		table.setBorderWidth(1);

		ff = table.getCellFormatter();
		ff.setStyleName(0, 0, "tablecol");
		ff.setStyleName(1, 0, "tablecol");
		ff.setStyleName(2, 0, "tablecol");
		ff.setStyleName(3, 0, "tablecol");
		ff.setStyleName(4, 0, "tablecol");
		ff.setStyleName(5, 0, "tablecol");
		ff.setStyleName(6, 0, "tablecol");
		ff.setStyleName(7, 0, "tablecol");
		ff.setStyleName(8, 0, "tablecol");
		
		table.setHTML(0, 0, cons.type());
		table.setHTML(1, 0, cons.jmsServer());
		table.setHTML(2, 0, cons.jmsServerVersion());
		table.setHTML(3, 0, cons.jmsServerUrl());
		table.setHTML(4, 0, cons.jmsFac());
		table.setHTML(5, 0, cons.jmsDestination());
		table.setHTML(6, 0, cons.jmsType());
		table.setHTML(7, 0, cons.jmsUser());
		table.setHTML(8, 0, cons.jmsPass());

		
		table.setHTML(0, 1, cons.jms());

		table.setHTML(1, 1, info.getServerUrl());
		table.setHTML(2, 1, jb.getServer());
		table.setHTML(3, 1, jb.getServerVersion());
		table.setHTML(4, 1, info.getFactoryUrl());
		table.setHTML(5, 1, info.getDestinationJndi());
		table.setHTML(6, 1, cons.jmsTypeQueue());
		// jmsUser = new TextBox();
		// jmsUser.setVisibleLength(32);
		// ;
		// jmsUser.setText(jb.getUser());
		table.setHTML(7, 1, "&nbsp;");
		// jmsPass = new PasswordTextBox();
		// jmsPass.setVisibleLength(32);

		// jmsPass.setText(jb.getPassword());
		table.setHTML(8, 1, "&nbsp;");

		p1.add(table);
		p1.add(new HTML("&nbsp;"));
		p1.add(new HTML("&nbsp;"));
		p1.add(new HTML("&nbsp;"));
		
		
		
		SoapBinding sb = s.getSoapBinding();
		table1 = new Grid(1,2);
		table1.setWidth("70%");
		cf = table1.getColumnFormatter();
		cf.setWidth(0, "20%");
		cf.setWidth(1, "60%");

		table1.setCellPadding(1);
		table1.setCellSpacing(1);
		table1.setBorderWidth(1);

		ff = table1.getCellFormatter();
		ff.setStyleName(0, 0, "tablecol");
		
		
		table1.setHTML(0, 0, cons.getResultService());
		table1.setHTML(0, 1, s.getGetResultServiceCode());
		
		p1.add(table1);
		p1.add(new HTML("&nbsp;"));
		p1.add(new HTML(cons.getResultServiceBinding()));
		
		table = new Grid(3, 2);
		table.setWidth("70%");
		cf = table.getColumnFormatter();
		cf.setWidth(0, "20%");
		cf.setWidth(1, "50%");

		table.setCellPadding(1);
		table.setCellSpacing(1);
		table.setBorderWidth(1);

		ff = table.getCellFormatter();
		ff.setStyleName(0, 0, "tablecol");
		ff.setStyleName(1, 0, "tablecol");
		ff.setStyleName(2, 0, "tablecol");
		
		
		table.setHTML(0, 0, cons.type());
		table.setHTML(1, 0, cons.url());
		table.setHTML(2, 0, cons.soapVersion());
		// table.setHTML(4, 0, cons.wsdl());
		// table.setHTML(5, 0, cons.endpoint());

		
		table.setHTML(0, 1, cons.soap());
		table.setHTML(1, 1, sb.getUrl());
		table.setHTML(2, 1, sb.getSoapVersion());
		
		p1.add(table);
		
		
		initWidget(p1);
		
	}

}
